package com.ty.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ty.common.annotation.Log;
import com.ty.common.core.controller.BaseController;
import com.ty.common.core.domain.AjaxResult;
import com.ty.common.enums.BusinessType;
import com.ty.system.domain.Enrollment;
import com.ty.system.service.IEnrollmentService;
import com.ty.common.utils.poi.ExcelUtil;
import com.ty.common.core.page.TableDataInfo;

/**
 * 驾校报名材料Controller
 *
 * @author
 * @date 2024-05-26
 */
@RestController
@RequestMapping("/system/enrollment")
public class EnrollmentController extends BaseController
{
    @Autowired
    private IEnrollmentService enrollmentService;

    /**
     * 查询驾校报名材料列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Enrollment enrollment)
    {
        startPage();
        List<Enrollment> list = enrollmentService.selectEnrollmentList(enrollment);
        return getDataTable(list);
    }

    /**
     * 获取驾校报名材料详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(enrollmentService.selectEnrollmentById(id));
    }

    /**
     * 新增驾校报名材料
     */
    @Log(title = "驾校报名材料", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Enrollment enrollment)
    {
        return toAjax(enrollmentService.insertEnrollment(enrollment));
    }

    /**
     * 修改驾校报名材料
     */
    @Log(title = "驾校报名材料", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Enrollment enrollment)
    {
        return toAjax(enrollmentService.updateEnrollment(enrollment));
    }

    /**
     * 删除驾校报名材料
     */
    @Log(title = "驾校报名材料", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(enrollmentService.deleteEnrollmentByIds(ids));
    }


    /**
     * 审核
     */
    @Log(title = "审核", businessType = BusinessType.OTHER)
    @PutMapping("/audit")
    public AjaxResult audit(@RequestBody Enrollment enrollment)
    {
        return toAjax(enrollmentService.audit(enrollment));
    }

}
